/*
 * @Author: yanjikun
 * @Date: 2022-06-07 11:30:57
 * @LastEditors: yanjikun
 * @LastEditTime: 2022-06-07 11:50:53
 * @Description: file content
 */

import { computed, ref, Slots, watchEffect } from 'vue'
import { BasicTreeProps } from '../basic-tree'

export type TreeState = ReturnType<typeof useTreeState>

export type UseTreeStateParams = {
  props: BasicTreeProps
  slots: Slots
}

export const useTreeState = ({ props }: UseTreeStateParams) => {
  const treeData = ref<BasicTreeProps['treeData']>([])
  const getBindValues = computed(() => {
    return props
  })
  watchEffect(() => {
    if (props.treeData) {
      treeData.value = props.treeData
    }
  })
  return {
    treeData,
    getBindValues,
  }
}
